/*
 * AddAccountPanel.java
 *
 * Created on 2008年6月8日, 下午8:30
 */

package gui;

import abstractmodel.IBook;
import javax.swing.DefaultComboBoxModel;

/**
 *
 * @author  littlechild
 */
public class AddAccountPanel extends javax.swing.JPanel {
    
    private String types[]=new String[]{"现金帐户","银行卡帐户","信用卡帐户"};
    IBook book;
    /** Creates new form AddAccountPanel */
    public AddAccountPanel(IBook bk) {
        book=bk;
        initComponents();
        init();
    }

    private void init() {
        this.jComboBox1.setModel(new DefaultComboBoxModel(types));
        this.jComboBox1.setSelectedIndex(2);
        this.jPanel1.setLayout(new java.awt.BorderLayout());
        this.jPanel1.add(new AddCreditAccountPanel(book),java.awt.BorderLayout.CENTER);
    }
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jComboBox1 = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();

        setPreferredSize(new java.awt.Dimension(600, 400));

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 569, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 494, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(238, 238, 238)
                .addComponent(jComboBox1, 0, 119, Short.MAX_VALUE)
                .addGap(232, 232, 232))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // TODO add your handling code here:
        int index=this.jComboBox1.getSelectedIndex();
        this.jPanel1.removeAll();
        switch(index) {
            case 0:
                this.jPanel1.add(new AddMoneyAccountPanel(book),java.awt.BorderLayout.CENTER);
                break;
            case 1:
                this.jPanel1.add(new AddDebitAccountPanel(book),java.awt.BorderLayout.CENTER);
                break;
            case 2:
                this.jPanel1.add(new AddCreditAccountPanel(book),java.awt.BorderLayout.CENTER);
                break;
        }
        this.updateUI();
    }//GEN-LAST:event_jComboBox1ActionPerformed
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
    
}
